<?php
/**
* TestGuest version1.0
*===================================
* Copy 2012-2016 yc60
* Web:http://www.yc60.com
*===================================
* Author:Pan
* Date:2016-12-20
*
*/
  header("Content-type:text/html;charset=utf-8");
  //定义个常量，用来授权调用includes里面的文件
  define('IN_TG','true');

  session_start();//一定要打开session才能接收数据

  //再定义个常量，用来指定本页的内容
  define('SCRIPT','register');

  //引入公共文件
  require dirname(__FILE__).'/includes/commom.inc.php';

  //判断是否提交了数据
  if($_GET['action']=='register'){
      //为了防止恶意注册，跨站攻击
      //调用核心函数库函数
      _check_code($_POST['code'],$_SESSION['code']);
      //引入验证文件
      include ROOT_PATH.'includes/register.func.php';
      //创建一个空数组,用存放接收的合法数据
      $_clean = array();
      // $_clean['username'] = $_POST['username'];
      // $_clean['password'] = $_POST['password'];//以此类推，可接受其他信息


      //去掉头尾的空格
      $_tmp_username = $_POST['username'];

      //可以通过唯一标识符来防止恶意注册，伪造表单跨站攻击等
      $_clean['uniqid'] = _check_uniqid($_POST['uniqid'],$_SESSION['uniqid']);
      //active 也是一个唯一标识符，用来激活刚注册的用户，方可登录
      $_clean['active'] =  _sha1_uniqid();
      $_clean['username'] = _check_username($_POST['username'],2,20);//这里可以自定义长度
      $_clean['password'] = _check_password($_POST['password'],$_POST['notpassword'],6);
      $_clean['question'] = _check_question($_POST['question'],4,30);
      $_clean['answer'] = _check_answer($_POST['question'],$_POST['answer'],2,20);
      $_clean['email'] = _check_email($_POST['email']);
      $_clean['qq'] = _check_qq($_POST['qq']);
      $_clean['url'] = _check_url($_POST['url']);
      print_r($_clean);
   }else{
      $_SESSION['uniqid'] = $_uniqid = _sha1_uniqid();;//这个就是唯一标识符
   }
 
  

?>
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8"/>
  <title>多用户留言系统--唯一标识符</title>
  <?php
     require ROOT_PATH.'includes/title.inc.php';
  ?>

  <script type="text/javascript" src="js/face.js"></script>
</head>
<body>

    <?php
        require ROOT_PATH.'includes/header.inc.php';
    ?>
    
    <div id="register">

        <h2>会员注册</h2>
       <!--将数据提交至本页面，必须做个名值对(?action=register)用来判断是否提交了数据-->
        <form method="post" name="register" action="register.php?action=register">
          <input type="hidden" name="uniqid" value="<?php echo $_uniqid ?>"/>
        <dl>
       	  <dt>请认真填写以下内容</dt>
       	  <dd>用 户 名:<input class="text" type="text" name="username">(*必填,至少两位)</dd>
          <dd>密　　码:<input class="text" type="password" name="password">(*必填,至少六位)</dd>
          <dd>确认密码:<input class="text" type="password" name="notpassword">(*必填,同上)</dd>
          <dd>密码提示:<input class="text" type="text" name="question">(*必填,至少两位)</dd>
          <dd>密码回答:<input class="text" type="text" name="answer">(*必填,至少两位)</dd>
          <dd>性　　别:<input  type="radio" name="sex" checked="checked" value="男">男<input  type="radio" name="sex"  value="女">女</dd>
          <dd><input type="hidden" name="face" value="face/m01.gif"><img src="face/m01.gif" alt="头像选择" id="faceimg"></dd>
          <dd>电子邮件:<input class="text" type="text" name="email"></dd>
          <dd>　 Q Q　:<input class="text" type="text" name="qq"></dd>
          <dd>主页地址:<input class="text" type="text" name="url" value="http://"></dd>
          <!--注册页面调用，直接以图片形式加载-->
          <dd>验 证 码:<input class="code" type="text" name="code"><img src="code.php" id="code"/></dd>
          <dd><input class="submit" type="submit" name="submit" value="注册"></dd>
        </dl>
        </form>

    </div>


   <?php
       require ROOT_PATH.'includes/footer.inc.php';      
   ?>

</body>
</html>














































